/* 来源于网络
https://blog.csdn.net/qq_33538554/article/details/86711151
*/

function batteryPercent(val) {
    let bcontent = document.getElementById("batteryIconContent");
    let label = document.getElementById("batteryIconContent");

    bcontent.style.setProperty('width', val/100*50+'px');
    if (val <= 10) {
        bcontent.style.setProperty('background', '#ff2939');
    }
    else if (val>10 && val <50) {
        bcontent.style.setProperty('background', "#ffd800");
    }
    else{
        bcontent.style.setProperty('background', '#9ad824');
    }
    label.innerText = ((val) + "%");

}